<%@ page import="com.example.demo_text.CourseDAO" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    String courseId = request.getParameter("course_id");
    String courseName = "";
    if (courseId != null && !courseId.isEmpty()) {
        courseName = CourseDAO.getCourseNameById(courseId);
    }
%>

<!DOCTYPE html>
<html>
<head>
    <title>上传视频</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Segoe UI', sans-serif;
            background: linear-gradient(135deg, #e0f7fa, #f3e5f5);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .upload-card {
            background: white;
            width: 90%;
            max-width: 600px;
            padding: 30px;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }

        h2 {
            text-align: center;
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-top: 15px;
            font-weight: bold;
        }

        input[type="text"] {
            width: 100%;
            padding: 10px;
            margin-top: 5px;
            border: 1px solid #ccc;
            border-radius: 6px;
        }

        button {
            margin-top: 20px;
            width: 100%;
            padding: 12px;
            background-color: #3b82f6;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 16px;
            cursor: pointer;
        }

        button:hover {
            background-color: #2563eb;
        }

        a.btn-back {
            display: inline-block;
            margin-top: 20px;
            padding: 10px 20px;
            background-color: #f3f4f6;
            color: #374151;
            border-radius: 8px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        a.btn-back:hover {
            background-color: #d1d5db;
            color: #111827;
        }
    </style>
</head>
<body>

<div class="upload-card">
    <h2>上传视频 - <%= courseName %></h2>
    <form action="UploadVideoServlet" method="post">
        <input type="hidden" name="course_id" value="<%= courseId %>"/>

        <label for="chapter_title">章节标题：</label>
        <input type="text" id="chapter_title" name="chapter_title" required/>

        <label for="video_url">请输入视频链接（支持 MP4、YouTube 等）：</label>
        <input type="url" id="video_url" name="video_url"
               placeholder="https://example.com/video.mp4" required/>

        <button type="submit">提交</button>
    </form>

    <div style="margin-top: 20px; text-align: center;">
        <a href="chapters.jsp?course_id=<%= courseId %>" class="btn-back">返回章节管理</a>
    </div>
</div>

</body>
</html>
